// 云对象教程: https://uniapp.dcloud.net.cn/uniCloud/cloud-obj
// jsdoc语法提示教程：https://ask.dcloud.net.cn/docs/#//ask.dcloud.net.cn/article/129
module.exports = {
	_before: function () { // 通用预处理器

	},
	/**
	 * 获取列表
	 * @param {string} openid 
	 * @param {number} pageIndex 
	 * @param {number} pageSize 
	 */
	getList(openid, pageIndex = 1, pageSize = 100) {
		const dbjql = uniCloud.databaseForJQL({
			clientInfo: this.getClientInfo()
		});
		const res = await dbjql.collection('mycollection').where({
			onlyid: openid
		}).skip((pageIndex - 1) * pageSize).limit(pageSize).get();
		return res;
	},
	/**
	 * 删除搜索记录
	 * @param {string} openid 
	 * @param {string} id 
	 */
	delete(openid, id) {
		const dbjql = uniCloud.databaseForJQL({
			clientInfo: this.getClientInfo()
		});
		const res = await dbjql.collection('mycollection').where({
			onlyid: openid,
			_id: id
		}).remove();
		return res;
	}
}
